package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TdParams;
import com.ruoyi.system.service.ITdParamsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 参数表Controller
 * 
 * @author ruoyi
 * @date 2025-02-19
 */
@RestController
@RequestMapping("/system/params")
public class TdParamsController extends BaseController
{
    @Autowired
    private ITdParamsService tdParamsService;

    /**
     * 查询参数表列表
     */
    @PreAuthorize("@ss.hasPermi('system:params:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdParams tdParams)
    {
        startPage();
        List<TdParams> list = tdParamsService.selectTdParamsList(tdParams);
        return getDataTable(list);
    }

    /**
     * 导出参数表列表
     */
    @PreAuthorize("@ss.hasPermi('system:params:export')")
    @Log(title = "参数表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdParams tdParams)
    {
        List<TdParams> list = tdParamsService.selectTdParamsList(tdParams);
        ExcelUtil<TdParams> util = new ExcelUtil<TdParams>(TdParams.class);
        util.exportExcel(response, list, "参数表数据");
    }

    /**
     * 获取参数表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:params:query')")
    @GetMapping(value = "/{paramsId}")
    public AjaxResult getInfo(@PathVariable("paramsId") String paramsId)
    {
        return success(tdParamsService.selectTdParamsByParamsId(paramsId));
    }

    /**
     * 新增参数表
     */
    @PreAuthorize("@ss.hasPermi('system:params:add')")
    @Log(title = "参数表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdParams tdParams)
    {
        return toAjax(tdParamsService.insertTdParams(tdParams));
    }

    /**
     * 修改参数表
     */
    @PreAuthorize("@ss.hasPermi('system:params:edit')")
    @Log(title = "参数表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdParams tdParams)
    {
        return toAjax(tdParamsService.updateTdParams(tdParams));
    }

    /**
     * 删除参数表
     */
    @PreAuthorize("@ss.hasPermi('system:params:remove')")
    @Log(title = "参数表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paramsIds}")
    public AjaxResult remove(@PathVariable String[] paramsIds)
    {
        return toAjax(tdParamsService.deleteTdParamsByParamsIds(paramsIds));
    }
}
